package com.sls.mall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lixue
 * @Title: MallRedissonConfig
 * @ProjectName sls_mall2021
 * @Description: TODO
 * @date 2021/5/413:54
 */
@Configuration
public class MallRedissonConfig {

    @Bean(destroyMethod = "shutdown")
    public RedissonClient malledisson() {

       // 1. 创建连接配置
       Config config = new Config();

       // 集群
//        config.useClusterServers()
//                // use "rediss://" for SSL connection
//                .addNodeAddress("redis://127.0.0.1:7181");

        // 单例
        config.useSingleServer().setAddress("redis://192.168.158.145:6379");

       // 2. 根据 config 创建出 redissionClient 示例
       return Redisson.create(config);
    }
}
